package service

import (
	"common/database/config"
	"num_srv/internal/models/dao"
	num "num_srv/proto"
)

func List(id *num.ListRequest) (*num.NumMessage, string) {
	var numMessage *dao.Num
	config.DB.Model(&numMessage).Where("id=?", id.NumId).Find(&numMessage).Limit(1)
	if numMessage.ID == 0 {
		return nil, "预约信息展示错误"
	}
	var doctorMessage *dao.User
	config.DB.Model(&doctorMessage).Where("id=?", numMessage.DoctorId).Find(&doctorMessage).Limit(1)
	if doctorMessage.ID == 0 {
		return nil, "医生信息展示失败"
	}
	var iolUserMessage *dao.IolUser
	config.DB.Model(&iolUserMessage).Where("id=?", numMessage.IolUserId).Find(&iolUserMessage).Limit(1)
	if iolUserMessage.ID == 0 {
		return nil, "患者信息展示失败"
	}
	sli := num.NumMessage{
		Name:           iolUserMessage.Name,
		Image:          iolUserMessage.Image,
		CardType:       int64(iolUserMessage.CardType),
		CardNum:        iolUserMessage.CardNum,
		WeChatNickName: iolUserMessage.WeChatNickName,
		Tel:            iolUserMessage.Tel,
		Who:            int64(iolUserMessage.Who),
		DoctorName:     doctorMessage.Name,
		Where:          int64(doctorMessage.Where),
		ObjRoom:        int64(doctorMessage.ObjRoom),
		Job:            int64(doctorMessage.Job),
		Title:          int64(doctorMessage.Title),
		NumPrice:       float32(doctorMessage.NumPrice),
		Cont:           doctorMessage.Cont,
		Type:           int64(numMessage.Type),
		Why:            numMessage.Why,
		Methods:        numMessage.Methods,
	}
	return &sli, ""
}
